/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Object;

import java.util.HashMap;
import java.util.Map;
import org.json.simple.JSONObject;
import share.ShareMacros;

/**
 *
 * @author LinhTA
 */
public class Pet {
    
   private String _type;
   private int _level;
    
    public Pet(String type, String level)
    {
        _level =Integer.parseInt( level);
        _type = type;
    }
    
    public Pet(String type)
    {
        _level= 0;
        _type = type; 
    }
    
    public int level()
    {
        return _level;
    }
    
    public String type()
    {
        return _type;
    }
    
    public int incrLevel(int val)
    {
        _level = _level + val;     
        return _level;
    }
    
    public String toString()
    {
        JSONObject data = new JSONObject();
        data.put(ShareMacros.LEVEL, String.valueOf(_level));
        data.put(ShareMacros.TYPE, _type);
        
        return data.toJSONString();
    }
    
    public Map<String,String> export()
    {
        Map<String,String> ret = new HashMap<String,String>();
        
        ret.put(ShareMacros.TYPE, _type);
        ret.put(ShareMacros.LEVEL, String.valueOf(_level));
        
        return ret;
    }
}
